package com.rico.deploy.service.impl;

import com.github.pagehelper.PageHelper;
import com.rico.deploy.entity.Course;
import com.rico.deploy.mapper.CourseMapper;
import com.rico.deploy.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 夏智力
 * @FileName CourseServiceImpl
 * @date 2021/5/2 17:45
 * @Software: IntelliJ IDEA
 */
@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper courseMapper;

    @Override
    public List<Course> selectAll() {
        return courseMapper.selectAll();
    }

    @Override
    public List<Course> selectAll(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        return courseMapper.selectAll();
    }

    @Override
    public List<Course> selectAll(Integer page, Integer limit, String keyword) {
        return null;
    }

    @Override
    public Course selectById(Integer id) {
        return courseMapper.selectByPrimaryKey(id);
    }

    @Override
    public int insertCourse(Course course) {
        return courseMapper.insert(course);
    }

    @Override
    public int deleteCourseById(Integer id) {
        return courseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateCourse(Course course) {
        return courseMapper.updateByPrimaryKey(course);
    }
}
